<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <div id="box" style="width: 100px;height: 100px;background: black;"></div>
</head>
<body>
    <script>
        // 案例演示1：创建一个正方形div，默认颜色为黑色，当鼠标移入div，背景颜色变为红色，当鼠标移出div，背景颜色变为绿色
        var box=document.getElementById("box")
        box.onmouseenter=function(){
            this.style.background="green"
        }
        box.onmouseleave=function(){
            this.style.background="red"
        }
    </script>
</body>
</html>